package net.zjitc.io.bufferedreader;

import java.io.*;

/**
 * @Author admin
 * @Date 2019/4/10 11:17
 */
public class Copyfile {
    public static void main(String[] args) {
        BufferedReader br=null;
        Reader in=null;
        BufferedWriter bw=null;
        Writer out=null;

        try {
            in=new FileReader("D:\\a.txt");
            br=new BufferedReader(in);
            out=new FileWriter("a.txt");
            bw=new BufferedWriter(out);
            String line;
            while ((line=br.readLine())!=null){
                bw.write(line);
                bw.newLine();
            }
            bw.flush();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {

                try {
                    if (in!=null){
                     in.close();
                   }
                    if (out!=null){
                        out.close();
                    }
                    if (bw!=null){
                        bw.close();
                    }
                    if (br!=null){
                        br.close();
                    }
            }catch (IOException e) {
                    e.printStackTrace();
                }
        }


    }
}
